package part15;

import java.util.LinkedList;
import java.util.Random;

/**
 * @author wcj
 * @Date 2021/5/29 17:50
 * @Version 1.0
 */
public class Part1514 {
    public static void serve(Teller t, Customer c) {
        System.out.println(t + " serve " + c);
    }

    public static void main(String[] args) {
        Random random = new Random(47);
        LinkedList<Customer> customers = new LinkedList<>();
    }
}

class Teller {
    private static long counter = 0;
    private final long id = counter++;

    private Teller() {
    }

    @Override
    public String toString() {
        return "Teller:" + counter;
    }

    public static <T> Generator<Teller> generator() {
        return new Generator<Teller>() {
            @Override
            public Teller next() {
                return new Teller();
            }
        };
    }
}

/**
 * 泛型应用于匿名内部类
 */
class Customer {
    private static long counter = 0;
    private final long id = counter++;

    private Customer() {
    }

    @Override
    public String toString() {
        return "Customer:" + counter;
    }

    public static <T> Generator<Customer> generator() {
        return new Generator<Customer>() {
            @Override
            public Customer next() {
                return new Customer();
            }
        };
    }
}